package com.test;

import com.Table.Movie;
import com.Table.User;
import com.model.DBUtil;
import com.model.operation.UserOperate;

import java.util.ArrayList;

/**
 * Created by lwx on 2016/12/3.
 */
public class test {
    private static DBUtil testdbutil;
    private static User testUser;
    private static ArrayList<Object> testlist;
    private static UserOperate testoperate = new UserOperate();

    public static void main(String[] args) {
        testdbutil = new DBUtil();
        long time = System.currentTimeMillis();
//        testUser = new User(
//                1,
//                "1871542112",
//                "123456",
//                "weixin",
//                "M",
//                50,
//                "你爱或不爱，我就在这里",
//                time
//        );
        //testdbutil.insert("User",testUser);
        //int answer=testdbutil.updateElem("User","coinnum",10,testUser);
        //testdbutil.deleteElem("User","coinnum",50);
        //testlist = testdbutil.getElemList("User", "com.Table.User", 0, -1);
//        User test3=(User)testdbutil.getElem("User","coinnum",50,"com.Table.User");
        //if(testdbutil.hasElem("User", "UserID", 1))//test hasElem, and it does work
        //System.out.print(true);
//        User test1 = (User) testlist.get(0);
//        User test2 = (User) testlist.get(1);
        //System.out.println(test3.getUserID() +" "+ test3.getCoinnum() +" "+ test3.getNickname()
        //      +" "+ test3.getPasswd() +" "+ test3.getSex() + " "+test3.getSignature() +" "+ test3.getSignupdate()+" "+test3.getUsername());

//        try {
//            Class<?> bean = Class.forName("com.Table.User");
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        }
        //String test=testoperate.IsUserValid("252722059@qq.com","123456");
//        String test=testoperate.UpdateSelfInformation("13531037810","111111","peifeng","F","feizhuliu");
//        System.out.print(test);
        //测试个人信息查看
//        testUser=testoperate.CheckSelfInformation("252722059@qq.com");
//        System.out.print(testUser.getUserID()+" "+
//                testUser.getUsername()+" "+
//                testUser.getPasswd()+" "+
//                testUser.getNickname()+" "+
//                testUser.getSex()+" "+
//                testUser.getCoinnum()+" "+
//                testUser.getSignature()+" "+
//                testUser.getSignupdate());
        //测试用户观看记录插入
//        String status = testoperate.AddUserMovieHistory("123456789@qq.com","你的名字");
//        System.out.println(status);
        //测试用户投币记录插入
//        String status = testoperate.AddCoin("123456789@qq.com","大家的名字");
//        System.out.println(status);
        int userID = 0;
        int pages = 2;
        int num = 10;
        StringBuilder CheckHistory =
                    new StringBuilder("select * from user_movie_history, movie " +
                            "where user_movie_history.userID = '" + userID +
                            "'and user_movie_history.movieID = movie.movieID" +
                            "Limit " + (pages - 1) * num + "," + num);
        System.out.println(CheckHistory);
        //测试查看用户观看记录，投币记录
//        ArrayList<Movie> testmovie=testoperate.CheckUserAddCoinHistory("123456789@qq.com");
//        for(int i=0;i<testmovie.size();i++)
//        {
//            System.out.print(testmovie.get(i).getMovieID()+" "+
//                    testmovie.get(i).getMoviename()+" "+
//                    testmovie.get(i).getUserID()+" "+
//                    testmovie.get(i).getCoinnum()+" "+
//                    testmovie.get(i).getUploadtime()+" "+
//                    testmovie.get(i).getTag()+" "+
//                    testmovie.get(i).getDescription()+" "+
//                    testmovie.get(i).getAddress()+" "+
//                    testmovie.get(i).getPicture());
//            System.out.print("\n");
//        }
        testoperate.AddUserMovieHistory("wslpf", "your name", 60);
    }
}
